#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int min_cost = 1e9;
	for (int i = 0; i < 3; ++i)
	{
		int price; int cnt;
		cin >> cnt >> price;
		int total = ((n + cnt - 1) / cnt) * price;
		if (total < min_cost)
		{
			min_cost = total;
		}
	}
	cout << min_cost << endl;
	return 0;
}

